using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class SO_FixedAssetsMap : EntityTypeConfiguration<SO_FixedAssets>
    {
        public SO_FixedAssetsMap()
        {
            // Primary Key
            this.HasKey(t => new { t.FA_ID, t.Life_Months_, t.Supplier, t.COST, t.Depreciable_Basis, t.Salvage_Value, t.Asset_Account, t.Expense_Account, t.Location });

            // Properties
            this.Property(t => t.FA_ID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Code)
                .HasMaxLength(20);

            this.Property(t => t.Description)
                .HasMaxLength(35);

            this.Property(t => t.Life_Months_)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Supplier)
                .IsRequired()
                .HasMaxLength(35);

            this.Property(t => t.Cost_Center)
                .HasMaxLength(50);

            this.Property(t => t.Category)
                .HasMaxLength(20);

            this.Property(t => t.Asset_Account)
                .IsRequired()
                .HasMaxLength(40);

            this.Property(t => t.Expense_Account)
                .IsRequired()
                .HasMaxLength(40);

            this.Property(t => t.User_Invoice_No)
                .HasMaxLength(8);

            this.Property(t => t.Invoice_No)
                .HasMaxLength(7);

            this.Property(t => t.Location)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Method)
                .HasMaxLength(19);

            // Table & Column Mappings
            this.ToTable("SO_FixedAssets");
            this.Property(t => t.FA_ID).HasColumnName("FA_ID");
            this.Property(t => t.Code).HasColumnName("Code");
            this.Property(t => t.Description).HasColumnName("Description");
            this.Property(t => t.Acq_Date).HasColumnName("Acq_Date");
            this.Property(t => t.Life_Months_).HasColumnName("Life(Months)");
            this.Property(t => t.Supplier).HasColumnName("Supplier");
            this.Property(t => t.Cost_Center).HasColumnName("Cost_Center");
            this.Property(t => t.Category).HasColumnName("Category");
            this.Property(t => t.COST).HasColumnName("COST");
            this.Property(t => t.Depreciable_Basis).HasColumnName("Depreciable_Basis");
            this.Property(t => t.Salvage_Value).HasColumnName("Salvage_Value");
            this.Property(t => t.Accumulated_Dep).HasColumnName("Accumulated_Dep");
            this.Property(t => t.Asset_Account).HasColumnName("Asset_Account");
            this.Property(t => t.Expense_Account).HasColumnName("Expense_Account");
            this.Property(t => t.Retired_Date).HasColumnName("Retired_Date");
            this.Property(t => t.User_Invoice_No).HasColumnName("User_Invoice_No");
            this.Property(t => t.Note).HasColumnName("Note");
            this.Property(t => t.Invoice_No).HasColumnName("Invoice_No");
            this.Property(t => t.Location).HasColumnName("Location");
            this.Property(t => t.Method).HasColumnName("Method");
        }
    }
}
